from rest_framework import serializers

from apps.goods.models import Goods
from muxi_shop_api.settings import IMAGE_URL


class GoodsSerializers(serializers.ModelSerializer):
    # 需要进行序列化处理的字段
    image = serializers.SerializerMethodField()
    create_time = serializers.DateTimeField(format='%Y-%m-%d %H:%M:%S')

    def get_image(self, obj):
        new_image_path = IMAGE_URL + obj.image
        return

    class Meta:
        model = Goods
        fields = "__all__"